var express = require('express');
var Router = express.Router();

// test
Router.get('/', function(req, res) {
	// test db
	var db = req.db;
	var device = db.get('device');
	device.insert({
		id: 'k1',
		detail: 'd1',
		user: 'u1'
	});

	device.find({}, {}, function(err, docs) {
		if (err) {
			res.send(err);
		} else {
			var data = '';
			docs.forEach(function(item) {
				console.log(item);
				data += JSON.stringify(item);
			});

			res.send(data);
		}
	});
	// res.send('test ok');
});

module.exports = Router;
